import { Ionicons } from "@expo/vector-icons";
import { FontSource, useFonts } from "expo-font";
import { StyleSheet, TextStyle } from "react-native";

// add font family for loading app for the first time
const useLoadedFontFamily = () => {
  const fonts: Record<keyof typeof FontFamilyEnum, FontSource> = {
    SPACE_MONO: require("../assets/fonts/SpaceMono-Regular.ttf"),
    CHARACTER_SOUL: require("../assets/fonts/CharacterSoul.ttf"),
    SONG_BAIT: require("../assets/fonts/SongYeti.ttf"),
    ...Ionicons.font,
  };
  const [Loaded, Error] = useFonts(fonts);
  return { Loaded, Error };
};

const useLoadedFontFamilyByAction = (fontFamily: keyof typeof FontFamilyEnum) => {
  return {
    fontFamily: fontFamily,
  } as TextStyle;
};

export { useLoadedFontFamily, useLoadedFontFamilyByAction };
